package com.whz.enumdemo;

/**
 * @Author: sinosoft
 * @Description: 太阳系行星枚举类
 * @Date: Create in 15:48 2021/5/13
 * @Modified By:
 */
public enum Planet {
    MERCURY(3.302e+23, 2.429e6),
    VENUS(4.302e+23, 4.429e6),
    EARTH(5.302e+23, 6.429e6),
    MARS(6.302e+23, 3.429e6),
    JUPITER(1.302e+23, 7.429e6),
    SATURN(5.302e+23, 6.429e6),
    URANUS(8.302e+23, 2.429e6),
    NEPTUNE(1.302e+26, 2.429e6);

    private final double mass; // 质量 单位 kg
    private final double radius; // 半径 单位 km
    private final double surfaceGravity; // 表面重力
    private static final double G = 6.67300E-11; // 重力系数

    Planet(double mass, double radius) {
        this.mass = mass;
        this.radius = radius;
        surfaceGravity = G * mass / (radius * radius);
    }

    public double getMass() {
        return mass;
    }

    public double getRadius() {
        return radius;
    }

    public double getSurfaceGravity() {
        return surfaceGravity;
    }

    public double surfaceWeight(double mass) {
        return mass * surfaceGravity; // F = ma
    }
}
